<template>
<avue-form :option="option" v-model="form" :upload-before="uploadBefore" @submit="handleSubmit">
  <template slot="group1Header">
    <h4>自定义表头</h4>
  </template>
</avue-form>
</template>
<script>
  import request from '@/router/axios';
  export default {
    data(){
      return {
        form:{
          text2:[],
        },
        option:{
          group:[
           {
              icon:'el-icon-info',
              label: '数据上传',
              prop: 'group2',
              column: [{
                propsHttp: {
                  res: 'data'
                },
                label: '文件上传',
                props:{
                  label:"name",
                  value:"url"
                },
                action: '/api/app/upload/imgs',
                prop: 'text2',
                type:"upload"
              }]
            }
          ]
        }
      }
    },
    methods:{
      uploadBefore(file, done) {
        console.log(file)
        done()
        this.form.text2=[];
        this.$message.success("上传前成功")
      },

      handleSubmit(){
       let arr= this.form.text2;
       if(!arr[0]){
         this.$message.warning("失败")
       }else{
        request({
          url: '/api/app/appexcel/excel',
          method: 'get',
          params: {
            path:arr[0].url
          }
        }).then(res=>{
          console.log(res);
        })
          this.$message.success("成功")
        }

      }
    }
  }
</script>
